#include "stdafx.h"
#include "LgSpritePropertyGem.h"

LgSpritePropertyGem::LgSpritePropertyGem(int nSpeed,int nFlyArea,const RectInBalloonElemnet_t &rect,int nMapHeight):
	LgSpriteProperty(nSpeed,nFlyArea,rect,nMapHeight),m_bBurst(true)
{
	m_eClassName=eLgSpritePropertyGem;
}

LgSpritePropertyGem::~LgSpritePropertyGem(void)
{
}

void LgSpritePropertyGem::Update(DWORD dwCurrentTime)
{
	if(!m_bShow)return;

	if (m_bBurst){
		DynamicLgSprite::Update(dwCurrentTime);
		if (m_fAnimationTimer>500){
			m_bBurst=false;
			m_fAnimationTimer=0;
		}else{
			m_ro = m_fSpeedy*(-12) * m_fAnimationTimer;
			m_vPosition.x=m_centerx+m_ro*cos(m_th);
			m_vPosition.y=m_centery+m_ro*sin(m_th);
		}
		
	}else{
		LgSpriteProperty::Update(dwCurrentTime);
	}

}
void LgSpritePropertyGem::PopUp(int x, int y)
{
	m_centery=(float)y;
	m_centerx=(float)x;
	m_vPosition.x=m_centerx;
	m_vPosition.y=m_centery;
	m_th=D3DXToRadian((float)(360-rand()%(180+1)));
	m_ro=0.0f;
	m_nLastTime=-1;
	m_bShow=true;
	m_bBurst=true;
}